package com.testDemo.jdk8.ex;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * @author: zouren
 * @date: 2021/5/31
 * @description:
 */
public class Ts {
    private static void printError(RuntimeException runtimeException){
        if(runtimeException.getStackTrace()!=null&&runtimeException.getStackTrace().length>0){
            System.out.println(getTrace(runtimeException));
//            log.error("{} {}",stackTrace.toString(),statusText);
        }
    }
    public static String getTrace(Throwable t) {
        StringWriter stringWriter = new StringWriter();
        stringWriter.append("aaaaa");
        PrintWriter writer = new PrintWriter(stringWriter);
        t.printStackTrace(writer);
        StringBuffer buffer = stringWriter.getBuffer();

        return buffer.toString();
    }
    public static void main(String[] args) {
        try {
            int i=0;
            int b = i/0;
        } catch (RuntimeException e) {

            printError(e);
        }

    }
}
